/**
 * @param {number[]} people
 * @param {number} limit
 * @return {number}
 */
// 贪心，注意该怎么证明
var numRescueBoats = function(people, limit) {
  people.sort((a, b) => a - b)
 let l = 0, r = people.length - 1
 let ans = 0
 while(l < r) {
   if(people[l] + people[r] <= limit) {
     ans++
     l++
     r--
   } else {
     ans++
     r--
   }
 }
 return l === r ? ans + 1 : ans
};